<?php
class MyZendX_View_Helper_Uploadify extends Zend_View_Helper_FormFile
{
	
	protected $_javascriptFiles = array(
		'/lib/swfobject/swfobject.js',
		'/lib/uploadify/jquery.uploadify.v2.1.4.min.js',
		'/lib/jquery.zend-uploadify.js'
	);

	protected $_stylesheetFiles = array(
		'/lib/uploadify/uploadify.css'
	);
	
	public function Uploadify($selector, $options = array())
	{
		$js = sprintf("jQuery('%s').zendUploadify(%s);", 
				$selector,
				Zend_Json_Encoder::encode($options));
		
		/* @var $jQuery ZendX_JQuery_View_Helper_JQuery_Container */
		$jQuery = $this->view->jQuery();
		$jQuery->enable()
				->addOnLoad($js);
				
		foreach($this->getStylesheetFiles() as $file) {
			$jQuery->addStylesheet($file);
		}
		foreach($this->getJavascriptFiles() as $file) {
			$jQuery->addJavascriptFile($file);
		}
	}
	
	public function getJavascriptFiles()
	{
		return $this->_javascriptFiles;
	}

	public function setJavascriptFiles(array $files)
	{
		$this->_javascriptFiles = $files;
		return $this;
	}

	public function getStylesheetFiles()
	{
		return $this->_stylesheetFiles;
	}

	public function setStylesheetFiles(array $files)
	{
		$this->_stylesheetFiles = $files;
		return $this;
	}
	
}